﻿package model.entity.product;

import java.util.Map;
import java.util.Map.Entry;

import javax.persistence.Entity;
import javax.persistence.Table;

@Entity
@Table(name="StaticToy")
public class StaticToy extends Toy {

	private String accessory;

	public String getAccessory() {
		return accessory;
	}

	public void setAccessory(String accessory) {
		this.accessory = accessory;
	}

	@Override
	public String toString() {
		return "StaticToy [accessory=" + accessory + ", ageRestriction="
				+ ageRestriction + ", size=" + size + ", material=" + material
				+ ", id=" + id + ", name=" + name + ", price=" + price
				+ ", image=" + image + ", quantity=" + quantity
				+ ", extraInfo=" + extraInfo + ", brand=" + brand + ", state="
				+ state + "]";
	}
	
	public static Map<String, Class<?>> fieldMap(){
		Map<String, Class<?>> fieldMap = Electronic.fieldMap();
		fieldMap.put("accessory", String.class);
		return fieldMap;
	}
	
	@Override
	public void insertData(Map<String, Object> valueMap) {
		super.insertData(valueMap);
		for (Entry<String, Object> entry : valueMap.entrySet()) {
			Object value = entry.getValue();
			
			//Dk rong
			if(entry.getValue() == null) continue;
			
			switch (entry.getKey()) {
			case "accessory":
				this.accessory = (String) value;
				break;
			default:
				break;
			}
		}
	}
}
